﻿module SVM

open SVMTypes
open SVMBinaryLib
open SVMLoad

let rec execute (program : string list) (current_state : SVM) (pc : int) : string =
  match program with
  | [] -> ""
  | ins :: instructions ->
      let parsed_ins,arg1,arg2,error = parse_instruction ins
      execute instructions svm (pc + 1)

let run (code : string list) : string =
  let test = parse_instruction "ADD [510] 1"
  ""
//  let svm,error = load_program program.Code (program.InstructionRange |> fst)
//  match svm with
//  | None -> error
//  | Some svm -> "Parse success"



[<EntryPoint>]
let main argv =
  let a = 0
  let a = a + 1
  System.Console.WriteLine("Simplified Virtual Machine")
  let code = System.IO.File.ReadAllLines("Program.svm") |> List.ofArray
  System.Console.WriteLine("Starting SVM...")
  let output = run code
  System.Console.WriteLine("SVM output: \n\n" + output)
  0 // return an integer exit code
